package com.pengtu.gsj.service.impl.gcjs;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.check.gcjs.XXRoadConstructionADao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.gcjs.XXRoadConstructionA;
import com.pengtu.gsj.service.gcjs.XXRoadConstructionAService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * 
 * XXRoadConstructionAServiceImpl
 * 
 * 2017年5月19日 下午3:28:11
 * 
 * @version 1.0.0
 *
 */
@Transactional
@Service
public class XXRoadConstructionAServiceImpl implements XXRoadConstructionAService {

	@Autowired
	private XXRoadConstructionADao xXRoadConstructionADao;
	
	@Autowired
	private SystemManageService systemManageService;

	@Override
	public List<XXRoadConstructionA> getXXRoadConstructionAs(QueryFilter queryFilter) {
		return xXRoadConstructionADao.find(queryFilter);
	}

	@Override
	public Page<XXRoadConstructionA> findXXRoadConstructionAs(Page<XXRoadConstructionA> page,
			QueryFilter queryFilter) {
		return xXRoadConstructionADao.findPage(page, queryFilter);
	}

	@Override
	public XXRoadConstructionA getXXRoadConstructionA(String id) {
		return xXRoadConstructionADao.get(id);
	}

	@Override
	public void saveXXRoadConstructionA(XXRoadConstructionA xXRoadConstructionA) {
		xXRoadConstructionADao.save(xXRoadConstructionA);
	}

	@Override
	public boolean deleteXXRoadConstructionA(XXRoadConstructionA xXRoadConstructionA) {
		if(xXRoadConstructionA.getAttachments() != null){
			for(Attachment attachment : xXRoadConstructionA.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		xXRoadConstructionADao.delete(xXRoadConstructionA);
		return true;
	}

	/**
	 * checkYear:
	 * 适用:验证县乡公路中的年份唯一
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@Override
	public Boolean checkYear(String year, String id) {
		return xXRoadConstructionADao.checkProperty("year", year, id);
	}

}
